﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;

namespace VisualView.Series
{
    /// <summary>
    /// 折线图
    /// </summary>
    /// <typeparam name="TX"></typeparam>
    /// <typeparam name="TY"></typeparam>
    public class LineXYSeries<TX, TY> : BaseXYSeries<TX, TY>
    {
        protected override Geometry CreateGeometry(int count, Func<int, double> getXFunc, Func<int, double> getYFunc)
        {
            var geometry = new StreamGeometry();
            if (count > 1)
            {
                using (var sc = geometry.Open())
                {
                    sc.BeginFigure(new Point(getXFunc(0), getYFunc(0)), false, false);
                    var points = new List<Point>(count - 1);
                    for (int i = 1; i < count; i++) points.Add(new Point(getXFunc(i), getYFunc(i)));
                    sc.PolyLineTo(points, true, true);
                }
            }
            return geometry;
        }
    }

    public class LineDoubleXYSeries : LineXYSeries<double, double> { }
    public class LineDoubleXDateTimeYSeries : LineXYSeries<double, DateTime> { }
    public class LineDoubleXTimeSpanYSeries : LineXYSeries<double, TimeSpan> { }

    public class LineDateTimeXYSeries : LineXYSeries<DateTime, DateTime> { }
    public class LineDateTimeXDoubleYSeries : LineXYSeries<DateTime, double> { }
    public class LineDateTimeXTimeSpanYSeries : LineXYSeries<DateTime, TimeSpan> { }

    public class LineTimeSpanXYSeries : LineXYSeries<TimeSpan, TimeSpan> { }
    public class LineTimeSpanXDoubleY : LineXYSeries<TimeSpan, double> { }
    public class LineTimeSpanXDateTimeY : LineXYSeries<TimeSpan, DateTime> { }

}
